package com.imti.mall.admin.controller;

import cn.hutool.core.util.ObjectUtil;
import com.imti.mall.admin.service.UmsAdminService;
import com.imti.mall.common.domain.CommonResult;
import com.imti.mall.feign.dto.UmsAdminLoginParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@Api(tags = "后台用户管理")
@RequestMapping("/api/v1/admin")
public class UserAdminController {

    @Autowired
    private UmsAdminService adminService;

    @ApiOperation(value = "管理员登录，成功返回token")
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult login(@RequestBody UmsAdminLoginParam umsAdminLoginParam) {

        if (ObjectUtil.isNull(umsAdminLoginParam)) {
            return CommonResult.failed();
        }
        return adminService.login(umsAdminLoginParam);
    }

}
